package io.renren.modules.business.controller;

import java.util.Map;

import io.renren.modules.business.entity.BusAssessmentScoreEntity;
import io.renren.modules.business.service.BusAssessmentScoreService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 打分表
 *
 * @author liao mengqing
 */
@RestController
@RequestMapping("business/assessment")
public class BusAssessmentScoreController {
    @Autowired
    private BusAssessmentScoreService busAssessmentScoreService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:assessment:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = busAssessmentScoreService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("business:assessment:info")
    public R info(@PathVariable("id") Long id){
		BusAssessmentScoreEntity busAssessmentScore = busAssessmentScoreService.getById(id);

        return R.ok().put("busAssessmentScore", busAssessmentScore);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:assessment:save")
    public R save(@RequestParam Map<String, Object> params){
        Long id = Long.parseLong((String) params.get("id"));
        Double score = Double.parseDouble((String) params.get("score"));
        busAssessmentScoreService.scoreDeveloper(id, score);
        return R.ok();
    }

}
